package com.yatuhashi.base;

import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TabHost;
import android.widget.Toast;

public class GlobalActivityManager extends TabActivity implements CategoryInterface {
    private TabHost tabHost;
    
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.frame_main);
        
        tabHost = getTabHost();
        TabHost.TabSpec spec;
        Intent intent;
        
        intent = new Intent().setClass(this, AActivity.class);
        spec = tabHost.newTabSpec(TAG1)
            .setIndicator(TAG1, null)
            .setContent(intent);
        tabHost.addTab(spec);
        
        intent = new Intent().setClass(this, BActivity.class);
        spec = tabHost.newTabSpec(TAG2)
            .setIndicator(TAG2, null)
            .setContent(intent);
        tabHost.addTab(spec);
        
        intent = new Intent().setClass(this, CActivity.class);
        spec = tabHost.newTabSpec(TAG3)
            .setIndicator(TAG3, null)
            .setContent(intent);
        tabHost.addTab(spec);
        
        intent = new Intent().setClass(this, DActivity.class);
        spec = tabHost.newTabSpec(TAG4)
            .setIndicator(TAG4, null)
            .setContent(intent);
        tabHost.addTab(spec);
        
        tabHost.getTabWidget().setVisibility(View.GONE);
    }
    
    public void showMenu(TAG tag) {
    	switch (tag) {
		case TAG1:
			tabHost.setCurrentTabByTag(TAG1);
			break;
		case TAG2:
			tabHost.setCurrentTabByTag(TAG2);
			break;
		case TAG3:
			tabHost.setCurrentTabByTag(TAG3);
			break;
		case TAG4:
			tabHost.setCurrentTabByTag(TAG4);
			break;
		default:
			tabHost.setCurrentTabByTag(TAG1);
			break;
		}
    }
    
    public void showMenu1(View v) {
    	showMenu(TAG.TAG1);
        Toast.makeText(this, TAG1, Toast.LENGTH_SHORT).show();
    }
    
    public void showMenu2(View v) {
    	showMenu(TAG.TAG2);
        Toast.makeText(this, TAG2, Toast.LENGTH_SHORT).show();
    }
    
    public void showMenu3(View v) {
    	showMenu(TAG.TAG3);
        Toast.makeText(this, TAG3, Toast.LENGTH_SHORT).show();
    }
    
    public void showMenu4(View v) {
    	showMenu(TAG.TAG4);
        Toast.makeText(this, TAG4, Toast.LENGTH_SHORT).show();
    }
}